package com.saydc.actions.capacitaciones;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.saydc.dao.EmpleadosDAO;
import com.saydc.forms.capacitaciones.EnviarCapacitacionForm;
import com.saydc.model.Empleado;

public class CapacitaEmpleadoAction extends Action {
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		EnviarCapacitacionForm capForm = (EnviarCapacitacionForm)form;
		EmpleadosDAO dao = EmpleadosDAO.getInstance();
		Empleado empleado = dao.buscarEmpleadoPorLegajo(capForm.getLegajo());
		
		if(empleado.agregarCapacitacionRealizada(capForm.getCapacitacion()) == false){
			return mapping.findForward("failure");
		}
		
		return mapping.findForward("success");
	}

}
